package cn.com.nes.site.action.user;

import java.sql.SQLException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.service.ExpandService;

@Controller("expand")
@RequestMapping("/expand")
public class ExpandAction {
	
	@Resource
	private ExpandService service;
	
	//PC-查询活动信息
	@RequestMapping(method = RequestMethod.POST, value = "/getExpandList")
	public @ResponseBody  PageData getExpandList(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getExpandList(req) ;
			return res;
	}
	
	//PC-保存活动信息
    @RequestMapping(method = RequestMethod.POST, value = "/saveExpand")
    public @ResponseBody
    PageData saveExpand(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = service.saveExpand(reqStatus.getReq());
        return res;
    }
    
    //PC-删除活动信息
    @RequestMapping(method = RequestMethod.POST, value = "/delExpand")
    public @ResponseBody
    PageData delExpand(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = service.delExpand(reqStatus.getReq());
        return res;
    }
    
    //PC-删除活动信息
    @RequestMapping(method = RequestMethod.POST, value = "/getExpandId")
    public @ResponseBody
    PageData getExpandId(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws SQLException {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = service.getExpandId(reqStatus.getReq());
        return res;
    }

}
